package pe.com.trestperu.common.util;

import java.util.List;
import java.util.Map;

import org.hibernate.transform.ResultTransformer;

/**
 * 
 *
 * @author Telly Tataje
 *
 */
public class AliasToEntityOrderedMapResultTransformer implements
		ResultTransformer {

	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unchecked")
	public Object transformTuple(Object tuple[], String aliases[]) {
		Map result = new OrderedMap(tuple.length);
		for (int i = 0; i < tuple.length; i++) {
			String alias = aliases[i];
			if (alias != null) {
				result.put(alias, tuple[i]);
			}
		}

		return result;
	}

	@SuppressWarnings("unchecked")
	public List transformList(List collection) {
		return collection;
	}

}
